﻿#region

using System.Collections.Generic;
using System.Web.Mvc;
using Should;
using TechTalk.SpecFlow;
using UserStoryTrackerDemo.Models;
using UserStoryTrackerDemo.Specs.Steps.Watin;

#endregion

namespace UserStoryTrackerDemo.Specs.Steps
{
	[Binding]
	public class ViewUserStoryListSteps : UserStoryStepsBase
	{
		private ViewResult _result;

		#region given

		[Given(@"I am on the user stories list page")]
		public void GivenIAmOnTheUserStoriesListPage()
		{
			WhenINavigateToUserStories();
		}

		#endregion

		#region when

		[When(@"I navigate to /UserStories")]
		public void WhenINavigateToUserStories()
		{
			_result = NavigateToListPage();
		}

		#endregion

		#region then

		[Then(@"I should be on the user stories page")]
		public void ThenIShouldBeOnTheUserStoriesPage()
		{
			ShouldBeOnListPage(_result);
		}

		[Then(@"I should see a list of user story entries")]
		public void ThenIShouldSeeAListOfUserStoryEntries()
		{
			((List<UserStoryVM>) _result.Model).Count.ShouldEqual(2);
		}

		[Then(@"user story entries have a completed")]
		public void ThenUserStoryEntriesHaveACompleted()
		{
			((List<UserStoryVM>) _result.Model)[0].Completed.ShouldBeFalse();
			WebBrowser.Current.Body.ToString().ShouldContain("Completed");
		}

		[Then(@"user story entries have a I can")]
		public void ThenUserStoryEntriesHaveAICan()
		{
			((List<UserStoryVM>) _result.Model)[0].ICan.ShouldNotBeEmpty();
			WebBrowser.Current.Body.ToString().ShouldContain("I can");
		}

		[Then(@"user story entries have a so that/because")]
		public void ThenUserStoryEntriesHaveASoThatBecause()
		{
			((List<UserStoryVM>) _result.Model)[0].SoThatBecause.ShouldNotBeEmpty();
			WebBrowser.Current.Body.ToString().ShouldContain("so that/because");
		}

		[Then(@"user story entries have an as a")]
		public void ThenUserStoryEntriesHaveAnAsA()
		{
			((List<UserStoryVM>) _result.Model)[0].AsA.ShouldNotBeEmpty();
			WebBrowser.Current.Body.ToString().ShouldContain("As a");
		}

		#endregion
	}
}